﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hybrid;
using System.Media;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Hybrid
{
    class SoundEffects
    {
        private SoundPlayer privateEnemyExplosion = new SoundPlayer(Application.StartupPath + "\\Sounds\\enemyexplosion.wav");
        private SoundPlayer privateProjectileFire = new SoundPlayer(Application.StartupPath + "\\Sounds\\projectilefire.wav");
        private SoundPlayer privatePlayerShipExplosion = new SoundPlayer(Application.StartupPath + "\\Sounds\\playershipexplosion.wav");
        private SoundPlayer privatePlayerShipLaserHit = new SoundPlayer(Application.StartupPath + "\\Sounds\\playershiplaserhit.wav");
        private SoundPlayer privateEnemyFire = new SoundPlayer(Application.StartupPath + "\\Sounds\\enemyfire.wav");
        private List<SoundPlayer> privateCountdown = new List<SoundPlayer>();

        [DllImport("winmm.dll")]
        private static extern long mciSendString(string strCommand, 
        StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);

        public SoundEffects()
        {
            privateEnemyExplosion.Load();
            privateProjectileFire.Load();
            privatePlayerShipExplosion.Load();
            privatePlayerShipLaserHit.Load();
            privateEnemyFire.Load();

            for (int i = 0; i <= 5; i++)
            {
                SoundPlayer count = new SoundPlayer(Application.StartupPath + "\\Sounds\\Countdown\\count" + i + ".wav");
                privateCountdown.Add(count);
                privateCountdown[i].Load();
            }
        }

        public void EnemyExplosion()
        {
            privateEnemyExplosion.Play();
        }

        public void ProjectileFire()
        {
            privateProjectileFire.Play();
        }

        public void PlayerShipExplosion()
        {
            privatePlayerShipExplosion.Play();
        }

        public void PlayerShipLaserHit()
        {
            privatePlayerShipLaserHit.Play();
        }

        public void EnemyFire()
        {
            privateEnemyFire.Play();
        }

        public void Ambience()
        {
            mciSendString("play Sounds\\ambience.mp3 REPEAT", null, 0, IntPtr.Zero);
        }

        public void Countdown(int i)
        {
            privateCountdown[i].Play();
        }

    }
}
